<!-- 行业分布 -->
<template>
  <div>
    <div style="width: 100%;height: 400px;">
      <barLineChart v-if="chartData.datas.length > 0" :chart-data="chartData" height="100%" @clickHandel="changeStage" />
      <div v-else class="noneData">
        <div>
          <svg-icon icon-class="none" class-name="none-icon" />
          <p>{{ $t('暂无数据') }}</p>
        </div>
      </div>
    </div>
    <div class="list-table mt20">
      <div class="area-header">
        <indirectProjectSummary ref="indirectProjectSummary" />
      </div>
    </div>
  </div>
</template>

<script>
import barLineChart from '@/views/chart/barLineChart.vue'
import indirectProjectSummary from '@/views/deal/bf/indirectProjectAnalysis/indirectProjectSummary.vue'
import { getIndustrialEcharts } from '@/api/bf/indirectProjectAnalysis/indirectProjectSummary'
export default {
  components: {
    barLineChart,
    indirectProjectSummary
  },
  data() {
    return {
      chartData: {
        datas: []
      },
      loading: false,
      listShow: false,
      currentArea: undefined
    }
  },
  mounted() {
    this.init()
  },
  methods: {
    init() {
      getIndustrialEcharts().then(response => {
        var numberArr = []
        var moneyArr = []
        var title = []
        if (response.data !== null && response.data.title !== null) {
          response.data.title.forEach(item => {
            title.push(item)
            numberArr.push(parseInt(response.data.numberArr === null ? 0 : (response.data.numberArr[item] === undefined ? 0 : response.data.numberArr[item])))
            moneyArr.push(parseFloat(response.data.moneyArr === null ? 0 : (response.data.moneyArr[item] === undefined ? 0 : (Number(response.data.moneyArr[item]) / 10000).toFixed(2))))
          })
        }
        this.chartData.xLabel = title
        this.chartData.legend = true
        this.chartData.yAxis2 = true
        this.chartData.legendLeft = 'center'
        this.chartData.yAxisName2 = ' '
        this.chartData.datas = [
          {
            type: 'bar',
            name: '金额',
            data: moneyArr
          },
          {
            type: 'line',
            name: '数量',
            data: numberArr
          }
        ]
      })
      this.changeStage(undefined)
    },
    changeStage(val, e) {
      console.log(val, e)
      if (this.currentArea === e.name) {
        this.currentArea = 'notNull'
      } else {
        this.currentArea = e.name
      }
      this.$refs.indirectProjectSummary.parentQueryParams.industryFirstLabel = this.currentArea
      this.$refs.indirectProjectSummary.getList()
    }
  }
}
</script>

<style scoped>

</style>
